package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class StrategyDetail extends BaseDomain{
    private String title;//标题

    private Date createTime;//创建时间

    private Date releaseTime;//发布时间

    private Integer sequence;//序号

    private StrategyCatalog catalog;//攻略分类

    private String coverUrl;//封面

    private Boolean state;//转态
    //文章内容对象
    private StrategyContent strategyContent;

    public String getStateName(){
        String temp ="不发布";
        if(state){
            temp="发布";
        }
        return temp;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap();
        map.put("id",id);
        map.put("title",title);
        map.put("releaseTime",releaseTime);
        map.put("sequence",sequence);
        if(catalog!=null) {
            map.put("catalogId", catalog.getId());
            map.put("strategyId",catalog.getStrategy().getId());
        }
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

}